package rmq

import (
	"gitee.com/sdynasty/clever/clog"
	"github.com/streadway/amqp"
)

/**
 * 生产消息
 */
func PublishMsgWork(msg []byte) {
	channel, err := MQInstance().GetMQChannel()
	if err != nil {
		clog.LogLogic().Println("GetMQChannel error : ", err)
		return
	}

	_, err = channel.QueueDeclare(
		// 队列名
		QueueName,
		//控制队列是否为持久的，当mq重启的时候不会丢失队列
		true,
		//是否为自动删除
		false,
		//是否具有排他性
		false,
		//是否阻塞
		false,
		//额外属性
		nil,
		)
	if err != nil {
		clog.LogLogic().Println(err)
		return
	}

	_ = channel.Publish("", QueueName,  false, false, amqp.Publishing{
		DeliveryMode:	amqp.Persistent,
		ContentType:	"text/plain",
		Body:			msg,
	})
}